package reflect;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        Person p =new Person();
        System.out.println(p);


        //先获取要实例化对象的类的类对象
       //Class cls=Class.forName("reflect.Person");
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入一个类名！");
        String className=scanner.nextLine();
        Class cls= Class.forName(className);
          Object o=cls.newInstance();
        System.out.println(o);
    }
}
